<template>
<div>
    
    <el-dialog  title="党委会编辑" :visible.sync="dialogVisible"  width='650px' append-to-body v-dialogDrag  :close-on-click-modal="false">
        <div  >
            <el-row class="myel-row" style="display: flex;">
                <div class="myel-span"><span>名称</span></div>
                <el-input placeholder="" v-model="rowdata.name" ></el-input>
            </el-row>
            <el-row class="myel-row" style="display: flex;">
                <div class="myel-span"><span>别名</span></div>
                <el-input placeholder="" v-model="rowdata.alias" ></el-input>
            </el-row>
            <el-row class="myel-row" style="display: flex;">
                <div class="myel-span"><span>创建时间</span></div>
                <el-input placeholder="" v-model="rowdata.createtime" ></el-input>
            </el-row>
            <el-row class="myel-row" style="display: flex;" v-if="needType==true">
                <div class="myel-span"><span>类型</span></div>
                <el-select v-model="type" placeholder="请选择">
                    <el-option v-for="item in options" :key="item.value" :label="item.label" :value="item.value"></el-option>
                </el-select>
            </el-row>   
            <el-row class="myel-row" style="display: flex;">
                <div class="myel-span" style="    width: 80%;margin: 0 auto;"><el-button type="primary" @click="save">确定</el-button></div>
            </el-row>   
        </div> 
    </el-dialog>
</div>
</template>
<script>
export default {
    data() {
        return {
            dialogVisible: false,
            needType:false,
            type:'',
            rowdata:{
                name:'',
                alias:'',
                dwid:-2,
                dzbid:-2,
                createtime:'',
            },
            options:[{
                value: '委员会',
                label: '委员会'
            }, {
                value: '党总支',
                label: '党总支'
            }],
        };
    },
    methods: {
        save(){
            let IsOK=true;
            if(this.rowdata.name=='' || this.rowdata.alias==''||this.rowdata.createtime==''){
                IsOK=false;
            }
            if(this.needType){
                if(this.type==''){
                    IsOK=false;
                }
            }
            if(IsOK==false){              
                this.$message("不能有空缺项！");
                return;
            }
            let pd=this.rowdata;
            pd.type=this.type;
            //添加到后台
            let postdata={
                type:"updatedwdzb",
                split:JSON.stringify(pd)
            }
            let _this=this;
            this.$Common.AjaxPost(postdata,true)
            .then(function(e){
                _this.$message("操作成功");
                _this.dialogVisible=false;
                _this.$emit('Hidedwedit');
            },function(){
                _this.$message("操作失败");
            })
            .catch(function(reason) {
                console.log('catch:', reason);
            });
        },
    },
}
</script>
<style >
</style>